﻿@{
    ViewBag.Title = "MpList";
    Layout = "~/Views/Shared/_adminLayout.cshtml";
}

@model IEnumerable<MP_Setting>
@section Head{
    <style>
        td{
            word-break:break-all;
        }
    </style>
}
<h4>公众号列表</h4>
<div>
    @Html.ActionLink("新增公众号", "MpEdit", null, new { Class = "btn btn-primary" })
</div>
<hr />
<div>
    <table class="table table-bordered table-condensed">
        <thead>
            <tr>
                <th>Logo</th>
                <th>公众号名称</th>
                <th>AppId</th>
                <th style="width:250px;">AccessToken</th>
                <th>是否更新</th>
                <th>最近更新时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @if (!string.IsNullOrEmpty(item.Logo))
                        {
                            <img height="50" src="@Url.Content("~/images/mp/" + item.Logo)" />
                        }
                    </td>
                    <td>@item.MpName</td>
                    <td>@item.AppId</td>
                    <td>@item.AccessToken</td>
                    <td>
                        @if (item.RefreshEnable)
                        {
                            <span class="text-success">是</span>
                        }
                        else
                        {
                            <span class="text-danger">否</span>
                        }
                    </td>
                    <td>@item.LastRefreshTime</td>
                    <td>
                        @Html.ActionLink("修改", "MpEdit", new { id = @item.Id }, new { Class = "btn btn-default" })
                        @using (Html.BeginForm("MpClose", "MpAdmin", new { id = @item.Id }, FormMethod.Post, new { onsubmit = "return marksure();", style = "display:inline-block" }))
                        {
                            <input type="submit" class="btn btn-default" value="切换是否更新" />
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
@section Scripts {
    <script src="~/scripts/jquery.form.js"></script>
    <script>
        function marksure() {
            return confirm("确认切换吗？");
        }
    </script>
}
